﻿@using VinhSon.Models
@model InfoTech.VinhSon.Bussiness.Category
@{
    int page;
    int.TryParse(ViewBag.Page + "",
                 out page);
    int count;
    int.TryParse(ViewBag.Count + "",
                 out count);
    if (count > Constant.NUMBER_ARTICLE_PER_PAGE)
    {
        int current = (page / 10) * 10;
        int pages = count / 10 + ((count % 10) > 0
                                          ? 1
                                          : 0);
    <div style="float: right">
        <ul class="pager1">
            @{
        if (page >= Constant.NUMBER_ARTICLE_PER_PAGE)
        {
            if ((page % Constant.NUMBER_ARTICLE_PER_PAGE) == 0)
            {
                current = ((page / Constant.NUMBER_ARTICLE_PER_PAGE) - 1) * Constant.NUMBER_ARTICLE_PER_PAGE + Constant.NUMBER_ARTICLE_PER_PAGE / 2;
            }
            else if ((page % Constant.NUMBER_ARTICLE_PER_PAGE) == 1)
            {
                current = current - Constant.NUMBER_ARTICLE_PER_PAGE / 2;
            }
        }
        for (int i = current; i < current + 10 && i < pages; i++)
        {
                <li><a class="@((i + 1) == page
                                                ? "active"
                                                : "")" href="@string.Format("{0}?page={1}",
                                                                            Model.GetUrl(),
                                                                            i + 1)">@(i + 1)</a></li>
        }
            }
        </ul>
        <div class="clear">
        </div>
        <br />
        Trang @page trong tổng số @pages trang.
    </div>
    }
}
